package acwing;

import java.io.*;
import java.util.*;

public class ac795 {
    static final int N = 100010;
    static int[] a = new int[N];
    static int[] s = new int[N];
    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = in.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        String[] s2 = in.readLine().split(" ");
        for(int i = 1; i <= n; i ++ ) {
            a[i] = Integer.parseInt(s2[i - 1]);
            s[i] = s[i - 1] + a[i];
        }
        while(m -- > 0){
            String[] s3 = in.readLine().split(" ");
            int l = Integer.parseInt(s3[0]);
            int r = Integer.parseInt(s3[1]);
            int res = s[r] - s[l - 1];
            System.out.println(res);
        }
    }
}
